package com.wang.serviceprovide.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/provider")
public class ProvideController {

    @Value("${server.port}")
    private String port;

    @SentinelResource(value = "hi", blockHandler = "aaa")
    @GetMapping("/hi")
    public String hi(String name){
        return "port" + port + "name" + name;
    }

    public String aaa(@RequestParam("name") String name, BlockException e){
        System.out.println(e);
        return "异常";
    }

    @SentinelResource("hi2")
    @GetMapping("/hi2/{name}")
    public String hi2(@PathVariable("name") String name){
        return "port" + port + "name" + name;
    }
}
